home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
util
/
termintr
/
part01
/
Terminator.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-11
|
2KB
|
102 lines
/*
The Terminator virus killer by Russell Wallace
See documentation file for details
Compiled with Aztec C v3.4a using precompiled INCLUDE files and 16-bit ints
Other module bootcode.o must be assembled with the Aztec assembler as
detailed in the file bootcode.a
NB - Must be linked with data/BSS in chip memory using +CDB with Aztec
linker, because trackdisk.device buffers have to be in chip memory
*/
struct MsgPort *diskport;
struct IOStdReq *diskreq;
struct FileHandle *window;
int unit; /* Disk drive 0..3 */
char buffer[2]; /* Drive number */
long code[256]; /* Buffer for boot block code */
extern long bootcode[20]; /* 80 bytes of actual code in separate module */
main (argc,argv)
int argc;
char **argv;
{
int i;
for (i=0;i<20;i++)
code[i]=bootcode[i]; /* Copy boot code into buffer */
/* This is so memory after actual code will contain zeros */
if (!(window=Open ("CON:0/50/640/120/The Terminator v1.0",MODE_NEWFILE)))
exit (30);
print ("The Terminator virus killer by Russell Wallace 6 Feb 1989\n\
WARNING - DO NOT USE ON A DISK WITH A CUSTOM BOOT BLOCK!\n");
RETYPE:
print ("\
Enter a number from 0 to 3 to protect/sterilize that floppy drive\n\
or type Q to quit: ");
Read (window,buffer,2L);
buffer[1]=0;
if (buffer[0]=='q' || buffer[0]=='Q')
{
Close (window);
return;
}
unit=buffer[0]-'0';
if (unit<0 || unit>3)
goto RETYPE;
print ("Installing boot code on drive ");
print (buffer);
print ("...\n");
/* Initialize for use of trackdisk.device */
if (!(diskport=CreatePort (0L,0L)))
{
Close (window);
exit (30);
}
if (!(diskreq=CreateStdIO (diskport)))
{
DeletePort (diskport);
Close (window);
exit (29);
}
if (OpenDevice (TD_NAME,(long)unit,diskreq,0L))
{
DeleteStdIO (diskreq);
DeletePort (diskport);
Close (window);
exit (28);
}
/* Write stuff */
diskreq->io_Length=1024;
diskreq->io_Data=code;
diskreq->io_Command=CMD_WRITE;
diskreq->io_Offset=0;
DoIO (diskreq);
/* Force update of track buffer to disk */
diskreq->io_Command=CMD_UPDATE;
DoIO (diskreq);
/* Turn motor off */
diskreq->io_Length=0;
diskreq->io_Command=TD_MOTOR;
DoIO (diskreq);
/* Clean up and go back to menu */
CloseDevice (diskreq);
DeleteStdIO (diskreq);
DeletePort (diskport);
goto RETYPE;
}
print (s)
char *s;
{
Write (window,s,(long)strlen (s));
}